'use strict';

module.exports = app => {
  const { STRING, INTEGER, DATE, BOOLEAN, DECIMAL } = app.Sequelize;

  const Place = app.model.define('place', {
    id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    code: { type: STRING(50), unique: true },
    description: STRING(200),
    store_id: INTEGER,
    store_floor: INTEGER,
    type: { type: INTEGER, comment: '库位性质 0：地面库位 1：货架库位' },
    shelf_code: { type: STRING(32), comment: '货架编码' },
    shelf_floor: { type: INTEGER, comment: '库位所在货架层数' },
    shelf_row: { type: INTEGER, comment: '库位所在货架列数' },
    bearing: { type: DECIMAL(19, 5), comment: '最大承重' },
    cbm: { type: DECIMAL(19, 5), comment: '存放体积' },
    area: { type: DECIMAL(19, 5), comment: '存放面积' },
    status: BOOLEAN,
    created_at: DATE,
    updated_at: DATE,
  });

  Place.associate = function() {
    app.model.Wms.Basic.Place.belongsTo(app.model.Wms.Basic.Store, { foreignKey: 'store_id' });
  };

  return Place;
};
